package leetcode.day;

public class AddDigits {

    public int addDigits(int num) {
        int res;
        while (true) {
            res = 0;
            while (num > 0) {
                res += num % 10;
                num /= 10;
            }
            if (res < 10) {
                break;
            }
            num = res;
        }
        return res;
    }
}
